package com.easylinkin.linkappapi.childinspection.controller;

import com.baomidou.mybatisplus.extension.api.ApiController;
import com.easylinkin.linkappapi.childinspection.entity.InspectionTaskEntity;
import com.easylinkin.linkappapi.childinspection.service.InspectionService;
import com.easylinkin.linkappapi.childinspection.vo.BaseVo;
import com.easylinkin.linkappapi.childinspection.vo.InspectionPersonVo;
import com.easylinkin.linkappapi.childinspection.vo.InspectionTaskVo;
import com.easylinkin.linkappapi.common.model.RequestModel;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import site.morn.rest.RestBuilders;
import site.morn.rest.RestMessage;

import javax.annotation.Resource;

/**
 * @author linWenLe
 * @Date: 2024/3/27
 * @Description: 巡检任务管理
 */
@RestController
@RequestMapping("/inspectionTask")
public class InspectionController extends ApiController {

    @Resource
    private InspectionService inspectionService;

    /***
     * 巡检任务列表
     * @return
     */
    @RequestMapping("getTaskList")
    public RestMessage getTaskList(@RequestBody RequestModel<InspectionTaskVo> restPage) {
        return RestBuilders.successBuilder(inspectionService.getTaskList(restPage)).build();
    }

    /***
     * 巡检人员列表
     * @return
     */
    @RequestMapping("getPersonList")
    public RestMessage getPersonList(@RequestBody InspectionPersonVo vo) {
        return RestBuilders.successBuilder(inspectionService.getPersonList(vo)).build();
    }

    /***
     * 新增巡检任务
     * @return
     */
    @RequestMapping("insert")
    public RestMessage insert(@RequestBody InspectionTaskVo entity) {
        inspectionService.insert(entity);
        return RestBuilders.successBuilder().message("新增成功").build();
    }

    /***
     * 修改巡检任务
     * @return
     */
    @RequestMapping("update")
    public RestMessage updatePoint(@RequestBody InspectionTaskEntity entity) {
        inspectionService.update(entity);
        return RestBuilders.successBuilder().message("修改成功").build();
    }

    /***
     * 删除巡检任务
     * @return
     */
    @RequestMapping("delete")
    public RestMessage delete(String id) {
        inspectionService.delete(id);
        return RestBuilders.successBuilder().message("删除成功").build();
    }

    /***
     * 巡检任务详情
     * @return
     */
    @RequestMapping("getTaskInfo")
    public RestMessage getTaskInfo(String id) {
        return  RestBuilders.successBuilder(inspectionService.getTaskInfo(id)).build();
    }

    /***
     * 今日巡检任务统计
     * @return
     */
    @RequestMapping("getAppTaskInfo")
    public RestMessage getAppTaskInfo(String id) {
        return  RestBuilders.successBuilder(inspectionService.getAppTaskInfo(id)).build();
    }

    /***
     * 今日巡检任务
     * @return
     */
    @RequestMapping("getTodayTaskInfo")
    public RestMessage getTodayTaskInfo(@RequestBody RequestModel<BaseVo> restPage) {
        return  RestBuilders.successBuilder(inspectionService.getTodayTaskInfo(restPage)).build();
    }

    /***
     * 巡检任务列表
     * @return
     */
    @RequestMapping("getAppTaskList")
    public RestMessage getTaskList() {
        return  RestBuilders.successBuilder(inspectionService.getAppTaskList()).build();
    }

    /***
     * 历史巡检任务列表
     * @return
     */
    @RequestMapping("getHistoryTaskList")
    public RestMessage getHistoryTaskList(@RequestBody RequestModel<BaseVo> restPage) {
        return  RestBuilders.successBuilder(inspectionService.getHistoryTaskList(restPage)).build();
    }
}
